 var html1=`<div class="header_top">
        <div class="header_top_part">
        <span>400-800-2220 （工作日9:30-18:30 节假日10:00-17:00）</span>
        <ul class="header_top_ul">
            <li>
            <a href="reg.html">免费注册</a>  
            <span>|</span>
            </li>
            <li>
                <a href="login.html">立即登录</a>  
                <span>|</span>
            </li>
            <li>
                <a href="404.html">大额充值</a>  
                <span>|</span>
            </li>
            <li>
                <a href="commonProblem.html">常见问题</a>  
                <span>|</span>
            </li>
            <li>
                <a href="companyCourse.html">关于我们</a>
            </li>
        </ul>
        </div>
        </div>
        <div class="header_bottom_out">
        <div class="header_bottom">
            <div>
                <img src="img/logo.png" alt="logo" class="logo_1"/>
                <img src="img/logo-2.png" alt="#" class="logo_2"/>
            </div>
            <ul class="header_bottom_ul">
                <li><a href="index.html" target="_top">首页</a></li>
                <li><a href="Intelligent_bidding.html" target="_top">智能投标</a></li>
                <li>
                    <p class="safe_1">平台保障</p>
                    <ul class="safe">
                        <li><a href="safe.html" target="_top">平台保障</a></li>
                        <li><a href="riskmanage.html">风控系统</a></li>
                    </ul>
                </li>
                <li><a href="my_account_all.html">我的账户</a></li>
            </ul>
        </div>
        </div>`

        var html2=`<div class="footer">
        <div class="footer_top">
            <div class="footer_top_left">
                <ul>
                    <li><a href="javascript:;" >关于我们</a></li>
                    <li><a href="companyCourse.html">公司历程</a></li>
                    <li><a href="contactUs.html">联系我们</a></li>
                </ul>
                <ul>
                    <li><a href="javascript:;" >媒体报道</a></li>
                    <li><a href="media.html">媒体报道</a></li>
                </ul>
                <ul>
                    <li><a href="javascript:;" >信息披露</a></li>
                    <li><a href="company_information.html">公司信息</a></li>
                    <li><a href="organize.html">组织架构</a></li>
                    <li><a href="teamManage.html">团队高管</a></li>
                    <li><a href="announcement.html">平台公告</a></li>
                </ul>
                <ul>
                    <li><a href="javascript:;" >帮助中心</a></li>
                    <li><a href="commonProblem.html">常见问题</a></li>
                    <li><a href="cardRule.html">卡券规则</a></li>
                </ul>
            </div>
            <div class="footer_top_right">
                <div class="footer_top_right_left">
                    <img src="./img/fwh.png" style="display:block" alt="#"/>
                    <img src="./img/dyh.png" style="display:none" alt="#"/>
                    <img src="./img/xz.png" style="display:none" alt="#"/>
                </div>
                <ul>
                    <li id="wechat">微信服务号</li>
                    <li id="wechat_">微信订阅号</li>
                    <li id="download">扫码下载APP</li>
                </ul>
                <div class="footer_top_right_right">
                    <img src="./img/logo-3.png" alt="#"/>
                    <p>工作日9:30-18:30</p>
                    <p>节假日10:00-17:00</p>
                    <h2>400 800 2220</h2>
                </div>
            </div>
        </div>
        <div class="clear"></div>
        <p>米众金融信息服务（上海）有限公司 | icp备案号：沪ICP备16026289号-1</p>
        <p>市场有风险    出借需谨慎</p>
        <p>
            <a href="javascript:;"><img src="./img/hy_83x30.png" alt="#"/></a>
            <a href="javascript:;"><img src="./img/WechatIMG164.png" alt="#"/></a>
            <a href="javascript:;"><img src="./img/cert.png" alt="#"/></a>
            <a href="javascript:;"><img src="./img/cnnic.png" alt="#"/></a>
        </p>
        </div>
        <div id="fixed_ul">
            <ul  id="u1">
                <li style="display:none"><img src="./img/pop_app.png" alt="#"></li>
                <li style="display:none"><img src="./img/pop_wechat.png" alt="#"></li>
                <li style="display:none"><img src="./img/phone.png" alt="#"></li>
            </ul>
            <ul id="u2">
                <li><img src="./img/app.png" alt="#"></li>
                <li><img src="./img/wechat.png" alt="#"></li>
                <li><img src="./img/Customer_service.png" alt="#"></li>
            </ul>
        </div>
         `

 var h=document.getElementById("header")
 //console.log(h)
 h.innerHTML=html1;

 var foot=document.getElementById("foot");
 //console.log(foot)
 foot.innerHTML=html2;

 var wd_2=document.getElementById("wechat_");
 var wd_1=document.getElementById("wechat");
 var dw=document.getElementById("download")

 wd_2.onmouseover=function(){
     var pic_2=wd_2.parentNode.previousElementSibling.children[1];
     var pic_1=wd_2.parentNode.previousElementSibling.children[0];
     var pic_3=wd_2.parentNode.previousElementSibling.children[2];
     pic_1.style.display="none"
     pic_3.style.display="none"
     pic_2.style.display="block"
 }
 wd_1.onmouseover=function(){
     var pic_2=wd_2.parentNode.previousElementSibling.children[1];
     var pic_1=wd_2.parentNode.previousElementSibling.children[0];
     var pic_3=wd_2.parentNode.previousElementSibling.children[2];
     pic_2.style.display="none"
     pic_3.style.display="none"
     pic_1.style.display="block"
 }

 dw.onmouseover=function(){
     var pic_2=wd_2.parentNode.previousElementSibling.children[1];
     var pic_1=wd_2.parentNode.previousElementSibling.children[0];
     var pic_3=wd_2.parentNode.previousElementSibling.children[2];
     pic_1.style.display="none"
     pic_2.style.display="none"
     pic_3.style.display="block"
 }


 var fixeds=document.getElementById("u2").children;
    var li_1=fixeds[0];
    var li_2=fixeds[1];
    var li_3=fixeds[2];
    li_1.onmouseover=function(){
      this.parentNode.previousElementSibling.children[0].style.display="block";
    };
    li_1.onmouseout=function(){
      this.parentNode.previousElementSibling.children[0].style.display="none";
    }
    li_2.onmouseover=function(){
      this.parentNode.previousElementSibling.children[1].style.display="block";
    };
    li_2.onmouseout=function(){
      this.parentNode.previousElementSibling.children[1].style.display="none";
    }
    li_3.onmouseover=function(){
      this.parentNode.previousElementSibling.children[2].style.display="block";
    };
    li_3.onmouseout=function(){
      this.parentNode.previousElementSibling.children[2].style.display="none";
    }



    function ajax({url,type,data,dataType}){
        return new Promise(function(open,err){
          var xhr=new XMLHttpRequest();
          xhr.onreadystatechange=function(){
            if(xhr.readyState==4&&xhr.status==200){
              if(dataType!==undefined  &&  dataType.toLocaleLowerCase()==="json")
              {var res=JSON.parse(xhr.responseText);
              }else {
                var res=xhr.responseText;
              }
              open(res);
            }
          }
          if(type.tolowerCase=="get"&&data!=undefined){
            url+="?"+data;
          }
          xhr.open(type,url,true);
          if(type.toLocaleLowerCase()==="post")
            xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded")
          if(type.toLocaleLowerCase()=="post"&&data!==undefined)
          {
          xhr.send(data);}
          else {xhr.send(null);}
        })
      }
    
ajax({
    url:"http://localhost:3000/user/check",
    type:"get",
    //data:,
    dataType:"json"
    }).then(function(result){
        console.log(result)
        if(result.length>0){
            var header_top_ul=document.getElementsByClassName("header_top_ul")[0]
            header_top_ul.innerHTML=`<li>
                                        <a>${result[0].uname}-你好</a>  
                                        <span>|</span>
                                    </li>
                                    <li>
                                        <a href="#" id="getOut">注销</a>  
                                        <span>|</span>
                                    </li>
                                    <li>
                                        <a href="404.html">大额充值</a>  
                                        <span>|</span>
                                    </li>
                                    <li>
                                        <a href="commonProblem.html">常见问题</a>  
                                        <span>|</span>
                                    </li>
                                    <li>
                                        <a href="companyCourse.html">关于我们</a>
                                    </li>`;
            var getOut=document.getElementById("getOut");
            console.log(getOut)
            getOut.onclick=function(){
                confirm("确定要退出登录吗？")
                var uname=result[0].uname
                var uid= result[0].uid
                ajax({
                    url:"http://localhost:3000/user/out",
                    type:"get",
                    //data:,
                    dataType:"json"
                    }).then(function(result){
                        if(result.code==1){
                            window.location.reload()
                        }
                    })
            }
        }   
    })   
    
